package com.example.bootasync.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.bootasync.entity.Prod;
import com.example.bootasync.entity.bo.ProdMsgBo;
import com.example.bootasync.mapper.ProdMapper;
import com.example.bootasync.service.IProdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author JiMing Zhou
 * @since 2023-06-02
 */
@Service
public class ProdServiceImpl extends ServiceImpl<ProdMapper, Prod> implements IProdService {

    /**
     * 根据商品id集合获取商品全部信息
     * @param ids 商品id集合
     * @return 商品全部信息
     */
    @Override
    public List<Prod> listProdByIds(List<Long> ids) {
        return this.list(new LambdaQueryWrapper<Prod>().in(Prod::getId, ids));
    }

    /**
     * 根据id获取详情
     * @param id 商品id
     * @return 商品详情
     */
    @Override
    public Prod getInfo(Long id) {
        return this.getById(id);
    }

    /**
     * mq更新商品
     * @param bo 更新商品
     */
    @Override
    public void updateProd(ProdMsgBo bo) {
        Prod prod = this.getById(bo.getProdId());
        prod.setNum(bo.getNum());
        this.updateById(prod);
    }
}
